package cn.iocoder.yudao.module.ent.convert.usertemplate;

import cn.iocoder.yudao.module.ent.controller.admin.usertemplate.vo.UserTemplateRespVO;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.Map;

@Mapper
public interface UserTemplateConverter {

    UserTemplateConverter INSTANCE = Mappers.getMapper(UserTemplateConverter.class);

    default UserTemplateRespVO convert(UserTemplateRespVO respVO, Map<Long, AdminUserRespDTO> userMap) {

        // 负责人
//        MapUtils.findAndThen(userMap, respVO.getc(), data -> respVO.setOwnerUserNickname(data.getNickname()));

        // 查询号码


//        // 负责人
//        List<String> collect = ListUtil.toList(caseDO.getOwnerUserId().split(",")).stream().filter(StrUtil::isNotEmpty).map(v ->
//                        userMap.get(Long.parseLong(v.toString())).getNickname())
//                .collect(Collectors.toList());
//
//        StringBuilder ownerUserName = new StringBuilder(StrUtil.EMPTY);
//
//        for(String str: collect) {
//            ownerUserName.append(str).append(",");
//        }
//        respVO.setOwnerUserName(ownerUserName.toString());

        return respVO;
    }


//    default PageResult<ReceiveDataRespVO> convert0(PageResult<ReceiveDataRespVO> pageResult, Map<Long, AdminUserRespDTO> userMap) {
//        List<ReceiveDataRespVO> dataList = CollectionUtils.convertList(pageResult.getList(), caseDO -> convert(caseDO, userMap));
//        PageResult<ReceiveDataRespVO> newResult = new PageResult<ReceiveDataRespVO>();
//        newResult.setList(dataList);
//        newResult.setTotal(pageResult.getTotal());
//        return newResult;
//    }
}
